package com.jxstjh.conch.handler.handler;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 渠道-处理器 映射关系  (Channel --> Handler)
 */
@Component
public class MessageHandlerHolder {

    private Map<Integer, MessageHandler> handlers = new HashMap<>(32);

    public void putMessageHandler(Integer channelCode, MessageHandler messageHandler) {
        handlers.put(channelCode, messageHandler);
    }

    public MessageHandler route(Integer channelCode) {
        return handlers.get(channelCode);
    }
}